#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#  testmail.py
#  
#  Copyright 2012 Ángel Coto <codiasw@gmail.com>
#  
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#  
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details (http://www.gnu.org/licenses/gpl.txt)
#  

import smtpd
import asyncore
from time import localtime, strftime

class MiSMTPServer(smtpd.SMTPServer):
    
    def process_message(self, peer, mailfrom, rcpttos, data):
        print '\n====================== ', strftime("%d/%m/%Y %H:%M:%S", localtime())
        print 'Mensaje recibido desde:', peer
        print 'Dirección remitente   :', mailfrom
        print 'Direcciones destino   :', rcpttos
        print 'Correo                :\n----------------------\n', data
        return

def main():
	
	server = MiSMTPServer(('127.0.0.1', 25), None)
#	server = smtpd.DebuggingServer(('127.0.0.1', 25), None)
	asyncore.loop()
	
	return 0

if __name__ == '__main__':
	main()

